import type { App } from 'vue';
import { createPinia } from 'pinia';
import { createPersistedState } from 'pinia-plugin-persistedstate';

const store = createPinia();

// 添加持久化插件
store.use(
  createPersistedState({
    // 全局配置
    key: (id) => `pinia-${id}`,
    storage: localStorage,
  }),
);

export function setupStore(app: App<Element>) {
  app.use(store);
}

export { store };
